<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item v-if="routeName=='rateofreturn'">{{$t('sidebar.dataReport')}}</el-breadcrumb-item>
        <el-breadcrumb-item v-if="routeName=='rateofreturn'">{{$t('newcrumbs.crumbsSev')}}</el-breadcrumb-item>
        <el-breadcrumb-item v-else>{{$t('newcrumbs.crumbsEig')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('totalManage.crumbsTwo')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <!-- -------------搜索查询栏------------------------ -->
    <search 
			:searchData="searchData" 
			@search="search" 
			@putExcel="putExcel" 
			:searchRight="true"
			:outputRight="$store.state.common.permiss[routeName].includes('export')"
    ></search>

    <!-- -------------表单显示栏------------------------ -->
    <p style="font-size:14px;margin-bottom:5px;">注：{{$t('long.no15')}}</p>
    <div class="table">
      <template>
        <el-table :data="tableData" size="small" 
          :summary-method="getSummaries"
          show-summary
          >
          <el-table-column align="center" prop="strRefundTime" :label="$t('public.no69')" width="140">
            <template slot-scope="scope">
              <span v-if="scope.row.strRefundTime!==null&&scope.row.strRefundTime!==undefined&&scope.row.strRefundTime!==''">{{scope.row.strRefundTime.slice(0,10)}}</span>
              <span v-else>{{$store.state.common.nullData}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="shouldReturnCount" :label="$t('totalManage.returnCount')">
          </el-table-column>
          <el-table-column align="center" prop="newCustomerRate" :label="$t('add.no80')">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.newCustomerRate)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="refundCount" :label="$t('add.no81')">
          </el-table-column>
          <el-table-column align="center" prop="d0" label="D0">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d0)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d1" label="D1">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d1)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d2" label="D2">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d2)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d3" label="D3">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d3)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d4" label="D4">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d4)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d5" label="D5">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d5)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d6" label="D6">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d6)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d7" label="D7">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d7)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d8" label="D8">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d8)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d9" label="D9">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d9)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d10" label="D10">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d10)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d15" label="D15">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d15)}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="d15More" label="D15+">
            <template slot-scope="scope">
              <span>{{$store.getters.twoPoint(scope.row.d15More)}}</span>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>

    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>

    <div class="foot"></div>

  </div>
</template>
<script>
import getApp from 'src/mixins/getApp.js';//app和apk下拉搜索
import putExcel from 'src/mixins/putExcel.js';//导出excel
export default {
  name: 'rateOfReturn',
  mixins:[ getApp,putExcel],
  data () {
    const searchData=[
      {
        type: 'rangePicker',
        label: 'totalManage.timeSelect',
        attr: 'searchTime',
        value: [],
      },{
        type: 'input',
        label: 'public.no25',
        attr: 'period',
        value: ''
      },{
        type: 'select',
        attr: 'userStatus',
        label: 'add.no86',
        option: this.$store.state.options.userType_option,
        value: '',
        langFlag: true,
      },{
        type: 'select',
        attr: 'appName',
        label: 'public.appName',
        option: [],
        value: '',
        langFlag: false,
      },{
        type: 'select',
        attr: 'appPackage',
        label: 'public.appPackage',
        option: [],
        value: '',
        langFlag: false,
      }
    ]
    return {
      routeName:this.$route.name,
      flag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      pageSize:10,
      searchTime: [],
      // 用户查询信息数据对应字段
      formInline: {
        period:'',
        dayBegin: '',
        dayEnd: '',
        userStatus: '',
      },
      // 当前页下标
      
      // 用户信息数据模拟
      tableData:[],
      tableData1:[],
      searchData:searchData,
      options1: [],// 借款周期下拉框
      putExcelUrl:this.$action.user_userSugExcel
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    getTableData () { // 获取回款率列表
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          ...this.formInline
        }       
      }
      this.$axios.post(this.$action.statistic_returnList,option).then(res=>{
        this.flag = true;
        if(res.code==200){
          this.tableData = res.data.collectionRateStatisticsPage.list;
          this.tableData1 = res.data.rateStatisticsAll;
          this.pagination.total = res.data.collectionRateStatisticsPage.total;
        }
      })
    },
    search (search) { // 点击查询按钮
      this.formInline = {
        period:search.period,
        userStatus:search.userStatus,
        dayBegin:search.searchTime?search.searchTime[0]:'',
        dayEnd:search.searchTime?search.searchTime[1]:'',
        appName:search.appName,
        appPackage:search.appPackage
      };
      if (this.flag) {
        this.pagination.currentPage = 1;
        this.flag = false;
        this.getTableData();
      }
    },
    getSummaries() {// 总和
      let sums;
      sums = [
        this.$t('public.addTotal'),
        this.tableData1.shouldReturnCount,
        this.$store.getters.twoPoint(this.tableData1.newCustomerRate),
        this.tableData1.refundCount,
        this.$store.getters.twoPoint(this.tableData1.d0),
        this.$store.getters.twoPoint(this.tableData1.d1),
        this.$store.getters.twoPoint(this.tableData1.d2),
        this.$store.getters.twoPoint(this.tableData1.d3),
        this.$store.getters.twoPoint(this.tableData1.d4),
        this.$store.getters.twoPoint(this.tableData1.d5),
        this.$store.getters.twoPoint(this.tableData1.d6),
        this.$store.getters.twoPoint(this.tableData1.d7),
        this.$store.getters.twoPoint(this.tableData1.d8),
        this.$store.getters.twoPoint(this.tableData1.d9),
        this.$store.getters.twoPoint(this.tableData1.d10),
        this.$store.getters.twoPoint(this.tableData1.d15),
        this.$store.getters.twoPoint(this.tableData1.d15More),
      ]
      return sums;
    }
  },
  mounted () {
    this.getApp().then(app=>{
      this.searchData[3].option=app.appName;
      this.searchData[4].option=app.appPackage;
    })
    this.getTableData();

  }
}
</script>

<style scoped lang="scss">
  
</style>
